//
//  SafeDangerCell.m
//  Estate
//
//  Created by wangdongdong on 2017/10/10.
//  Copyright © 2017年 ttsx. All rights reserved.
//

#import "SafeDangerCell.h"

@implementation SafeDangerCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.leftView.backgroundColor = UIColorFromRGB(0x009688);
    self.nameLabel.textColor = mainTitleColor;
    self.describeLabel.textColor = mainTitleColor;
    self.appraiseLabel.textColor = mainTitleColor;
    
    self.describeText.textColor = otherColor;
    self.conformLabel.textColor = subtitleColor;
    
    // 检查情况描述
    self.describeText.placeholder = @"请输入检查情况描述";
    self.describeText.layer.borderColor = [[UIColor colorWithRed:215.0 / 255.0 green:215.0 / 255.0 blue:215.0 / 255.0 alpha:1] CGColor];
    self.describeText.layer.borderWidth = 0.6f;
    self.describeText.layer.cornerRadius = 6.0f;
    self.describeText.delegate = self;
    
    // 监理评价(是否符合要求)
    [self.conformSwitch addTarget:self action:@selector(supervisionEvaluation:) forControlEvents:UIControlEventValueChanged];
}

// 不可编辑
- (void)isNoEdit {
    self.describeText.editable = NO;
    self.conformSwitch.enabled = NO;
}

#pragma mark UITextFieldDelegate(检查情况描述)
- (void)textViewDidChange:(UITextView *)textView {
    if (self.checkSituationBlock) {
        self.checkSituationBlock(textView.text);
    }
}

// 监理评价(是否符合要求)
- (void)supervisionEvaluation:(UISwitch *)switchButton {
    BOOL isButtonOn = [switchButton isOn];
    
    if (self.supervisionEvaluationBlock) {
        if (isButtonOn) {
            self.supervisionEvaluationBlock(@"1");
            
        } else {
            self.supervisionEvaluationBlock(@"0");
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
